/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vn.ac.c0910g.assignment.Entity;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author BachLe
 */
@Stateless
public class AdministratorFacade extends AbstractFacade<Administrator> {
    @PersistenceContext(unitName = "Alluring_Decors-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public AdministratorFacade() {
        super(Administrator.class);
    }

    public Administrator getUserByUsername(String username, String pass){
        return (Administrator)em.createQuery("SELECT a FROM Administrator a WHERE a.userName = :userName and a.password = :password")
                .setParameter("userName", username).setParameter("password", pass).getSingleResult();
    }
}
